﻿<?php
session_start();
include("admin_resist_mdl.php");
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

include("../../Modules/conn.php");

$mssv_old = $_GET["mssv"];
$mssv_new = $_POST["txtMSSV"];
$hoten = $_POST["txtHoTen"];

// Kiem tra mssv
$queryMSSV = "select * from sinh_vien where MSSV = '$mssv_new' and MSSV <> '$mssv_old')";
$resultMSSV = mysql_query($queryMSSV, $conn) or die(mysql_error());
$count = mysql_num_rows($resultMSSV);

if ($count > 0)
{
	header("Location: ../View/admin_cpanel.php?part=editsv&mssv=$mssv_old&info=dupmssv");
}
else
{
	// Sua thong tin sinh vien
	$queryUpdSV = "update sinh_vien set MSSV = '$mssv_new', TEN_SV = '$hoten' where MSSV = '$mssv_old'";
	mysql_query($queryUpdSV, $conn) or die(mysql_error());
	
	mysql_close();
	header("Location: ../View/admin_cpanel.php?info=editsvsucc");
}

?>